package com.colorlight.cloud.all_event;

import com.colorlight.cloud.common.exception.ParameterException;
import com.colorlight.cloud.common.model.ExceptionEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author Demon
 * @description 所有协议类型的统一定义
 * @date 10/5/2024  上午11:45
 */
@Getter
public enum AllProtocolType {
	/**
	 *
	 */
	
	NAME_STRUCT_GRAND_SHOW("GrandShow"),
	
	NAME_STRUCT_XM("Xm"),
	
	NAME_STRUCT_SL10("Sl10"),
	
	NAME_STRUCT_PLAY_BOX("PlayBox"),
	
	NAME_STRUCT_ACU35("ACU35"),
	
	NAME_STRUCT_A10("A10"),
	
	NAME_STRUCT_COMPLETE("Complete"),
	;
	
	
	private final String type;
	
	AllProtocolType(String type) {
		this.type = type;
	}
	
	public String getType() {
		return type;
	}
	
	
	
	/**
	 * @param type 输入类型
	 * @return 对应的类型
	 */
	public static AllProtocolType getProtocolTypeByteType(String type) {
		Objects.requireNonNull(type, "ParamIndexEnum can not be null.");
		return Arrays.stream(AllProtocolType.values())
				.filter(e -> e.type.equalsIgnoreCase(type))
				.findFirst()
				.orElseThrow(() -> new ParameterException(ExceptionEnum.NOT_EXIST_ENUM));
	}
}
